import {
  createRouter,
  createWebHistory,
  createWebHashHistory,
  RouteRecordRaw,
} from 'vue-router';

import Home from '../views/Home.vue';

// 基础路由
const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    component: Home,
    redirect: '/router',
    children: [
      { path: '/router', component: () => import('@views/Router.vue') },
      { path: '/search', component: () => import('@views/Search.vue') },
      { path: '/optimize', component: () => import('@/views/Optimize.vue') },
      { path: '/analyze', component: () => import('@/views/Analyze.vue') },
    ],
  },
  {
    path: '/:catchAll(.*)',
    name: '404',
    component: () => import('@views/404.vue'),
  },
];

const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

export default router;
